Understanding And Mitigating Copying In Diffusion Models